<head>

<title>$!app_name</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <link href="${base}/include/css/msg.css" rel="stylesheet" type="text/css"/>
    <link href="${base}/include/css/default.css" rel="stylesheet" type="text/css"/>
	<script type='text/javascript'>
		var CONTEXTPATH = '${base}';
	</script>
    <script src="${base}/include/js/main.js"></script>
    <script src="${base}/include/js/string.js"></script>
    
	<script type="text/javascript"
	src="${base}/include/controls/ztree/jquery.ztree.core-3.5.min.js"></script> 
	<script type="text/javascript" src="${base}/include/controls/ztree/jquery.ztree.excheck-3.5.min.js"></script>
    <script type="text/javascript" src="${base}/include/controls/ztree/jquery.ztree.exedit-3.5.min.js"></script>
	<link rel="stylesheet" href="${base}/include/controls/ztree/zTreeStyle/zTreeStyle.css" type="text/css">

</head>

<body class="dialogBody">
<script type="text/javascript">
    
    var setting = {
			view: {
				selectedMulti: false,
                nameIsHTML: true
			},
            check: {
                    enable: true
            }
            ,
			data: {
				simpleData: {
					enable: true
				}
			}
		};
        var zNodes =#if($str)$!str #else [] #end ;
        var ztreeObj;
		jQuery(document).ready(function(){
			ztreeObj=jQuery.fn.zTree.init(jQuery("#treeDemo"), setting, zNodes);
		});
        function getIdsTree(){
            var nodes = ztreeObj.getCheckedNodes();
            var ids="";           
            for(var i=0;i<nodes.length;i++){
               ids += nodes[i].id + ",";              
            }
            if(ids!=""&&ids!=","){           	
                document.getElementById("checkids").value=ids;
                return true;
            }
            return false;

        }

function dosave()
{

    if (document.form1.unitid.value=="")
    {
         Dialog.alert("请选择机构！");
         return false;
    }
   
    if(document.form1.nameflag.value==1){
    	Dialog.alert("用户名已存在！");
    	return false;
    }
        if (document.form1.password.value==document.form1.password2.value){
        if(getIdsTree()){           
           return true;          
        }
        else{
            Dialog.alert("修改当前登陆用户时，不可把角色全部勾除，否则会丢失全部资源权限！");                                
          return false;	
        }
        }else{
            Dialog.alert("两次输入密码不一致！");
            document.form1.password2.focus();
            return  false;
        }
   
}
function checkloginname()
{
	var newname = document.form1.loginname.value;
	if('$!obj.loginname' == newname){
		document.form1.nameflag.value = 0;
		return;
	}
	jQuery.ajax({
		url : "${base}/private/sys/user/ajaxname",
		data : jQuery("#form1").serialize(),
		success : function (res) {	
			if(res=="true"){
				Dialog.alert("该用户名已存在",function(){
					 document.form1.nameflag.value = 1;
                });	
			}else{
				     document.form1.nameflag.value = 0;
			}		                      
		},
		fail : function(res) {
			Dialog.alert("系统错误?!");
		}
	});   
}
 </script>
<form name='form1' id="form1" method='post' >
     <input type="hidden" name="checkids" id="checkids" value="">
     <input type="hidden" name="nameflag" id="nameflag" value="0">   
     <input type="hidden" name="unitid" id="unitid" value="$!obj.unitid">
	 <input type="hidden" name="id" id="id" value="$!obj.id">
     <input type="hidden" name="oldloginname" id="oldloginname" value="$!obj.loginname">
     
    
    <table width="570" height="207" align="center" cellpadding="2" cellspacing="0">
    <tr>
      <td height="10"></td>
      <td></td>
    </tr>
    <tr>
      <td width="311" valign="top">
          <div id="con_one_1">

   <fieldset>
    <legend><label>基本信息</label></legend>
      <table width="100%" border="0" cellpadding="0" cellspacing="0">

                    <tr>
                        <td align="right" height="30">所属机构：</td>
                        <td>
                        $!unit.name
                      </td>
                    </tr>


        <tr>
          <td width="39%" height="30" align="right" >用户名：</td>
          <td width="61%"><input name="loginname" id="loginname"  type="text" onblur="checkloginname()" maxlength="20"
                 value="$!obj.loginname" verify="登录名|NotNull"/></td>
        </tr>
        <tr>
          <td height="30" align="right" >姓名：</td>
          <td><input name="realname" id="realname" value="$!obj.realname"  type="text" maxlength="20" verify="姓名|NotNull"/></td>
        </tr>
                    <tr>
                        <td height="30" align="right">密码：</td>
                        <td><input type="password" name="password" id="password" value="" maxlength="20" >
                        </td>
                    </tr>

                    <tr>
                        <td height="30" align="right">确认密码：</td>
                        <td><input type="password" name="password2" id="password2" value="" maxlength="20" >
                        </td>
                    </tr>
<tr>
                        <td align="right" height="30">用户描述：</td>
                        <td><input type="text" name="descript" id="descript" value="$!obj.descript" maxlength="50">
                        </td>
                    </tr>

                    <tr>
                        <td align="right" height="30">职务：</td>
                        <td><input type="text" name="pozition" id="pozition" value="$!obj.pozition" maxlength="20">
                        </td>
                    </tr>

                    <tr>
                        <td align="right" height="30">地址：</td>
                        <td><input type="text" name="address" id="address" value="$!obj.address" maxlength="100">
                        </td>
                    </tr>

                    <tr>
                        <td align="right" height="30">电话：</td>
                        <td><input type="text" name="telephone" id="telephone" value="$!obj.telephone" maxlength="20">
                        </td>
                    </tr>

                    <tr>
                        <td align="right" height="30">手机：</td>
                        <td><input type="text" name="mobile" id="mobile" value="$!obj.mobile" maxlength="11"  verify="手机|Int">
                        </td>
                    </tr>

                    <tr>
                        <td align="right" height="30">电子邮件：</td>
                        <td><input type="text" name="email" id="email" value="$!obj.email" maxlength="50"  verify="电子邮件|Email">
                        </td>
                    </tr>

                    <tr>
                        <td align="right" height="30">QQ号码：</td>
                        <td><input type="text" name="linkqq" id="linkqq" value="$!obj.linkqq" maxlength="50"  verify="QQ号码|Int">
                        </td>
                    </tr>
				<tr>
                        <td align="right" height="30">个人主页：</td>
                        <td><input type="text" name="linkweb" id="linkweb" value="$!obj.linkweb" maxlength="250" >
                        </td>
                    </tr>
                    <tr>
                        <td height="30" align="right">激活状态：</td>
                        <td>
                        <select name="state" id="state" class="selectText" style="width:65px;">
                        <option  value="0">启用</option>
                         <option  value="1">禁用</option>
                        </select>
                            <script type="text/javascript">selected(document.form1.state,"$!obj.state")</script>

                        </td>
                    </tr>
      </table></fieldset>
      </div>
      </td>
      <td  width="240"  valign="top">
	  <fieldset>
		<legend><label>所属角色</label></legend>
		  <table width="100%" border="0" cellpadding="2" cellspacing="0">
			<tr>
			<td>
	    <div ztype='_Tree' style='-moz-user-select:none;height:370px;width:240px;'
                             onselectstart='stopEvent(event);' id='tree1' class='treeItemN'>
            <ul id="treeDemo" class="ztree" style="height:350px;width:230px;overflow-x:hidden"></ul>
                        </div>

		</td>
		 </tr>
      </table></fieldset>
	  </td>
    </tr>
	</table>
</form>
</body>

</html>